package com.example.module_main.view

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.lib_base.base.BaseFragment
import com.example.module_main.R
import com.example.module_main.adapter.HomeAdapter
import com.example.module_main.databinding.FragmentHomeBinding
import com.example.module_main.entity.HomeEntity
import com.example.module_main.entity.HomeEntityItem
import com.example.module_main.viewmodel.HomeViewModel
import com.google.gson.Gson
import dagger.hilt.android.AndroidEntryPoint

class HomeFragment : BaseFragment<FragmentHomeBinding,HomeViewModel>() {
    lateinit var homeAdapter: HomeAdapter
    override fun initView() {
        homeAdapter= HomeAdapter()
        binding.rv.adapter=homeAdapter
        binding.rv.layoutManager=LinearLayoutManager(requireContext())
        viewModel.getNotice(2,10)
//        binding.rv.setOnTouchListener { v, event ->
//            // 直接返回 true，禁止滑动
//            true
//        }
    }

    override fun initData() {
        viewModel.getSuccess.observe(this){
            homeAdapter.data.clear()
            homeAdapter.data.addAll(it)
            homeAdapter.notifyDataSetChanged()
        }
    }

}
